import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
    //一级路由
    {
        path: '/',
        name: 'MainView',
        redirect: '/index',
        component: () =>
            import ('../views/MainView'),
        //二级路由
        children: [{
                path: 'index',
                name: 'Index',
                meta: {
                    index: 0
                },
                component: () =>
                    import ('../views/Index')
            },
            {
                path: 'menu',
                name: 'Menu',
                meta: {
                    index: 1
                },
                component: () =>
                    import ('../views/Menu')
            },
            {
                path: 'order',
                name: 'Order',
                meta: {
                    index: 2
                },
                component: () =>
                    import ('../views/Order')
            },
            {
                path: 'shopcart',
                name: 'ShopCart',
                meta: {
                    index: 3
                },
                component: () =>
                    import ('../views/ShopCart')
            },
            {
                path: 'mine',
                name: 'Mine',
                meta: {
                    index: 4
                },
                component: () =>
                    import ('../views/Mine')
            },

        ]
    },
    {
        path: '/login',
        name: 'Login',
        component: () =>
            import ('../views/Login')
    }
]

const router = new VueRouter({
    routes
})

export default router